package com.haltakov.letterjumble.game.api;

import java.util.List;

import com.haltakov.letterjumble.ai.ScrabbleAI;
import com.haltakov.letterjumble.ai.TreeDictionary;

public class ComputerPlayer extends Player {

	public ComputerPlayerDifficulty getDifficulty() {
		return difficulty;
	}

	ComputerPlayerDifficulty difficulty;
	ScrabbleAI ai;
	
	
	public ComputerPlayer(GameController game, String name, PlayerType type, ComputerPlayerDifficulty difficulty, int score, List<BoardWord> wordHistory) {
		super(game, name, type, score, wordHistory);
		
		if (game.getDictionary() instanceof TreeDictionary)
			ai = new ScrabbleAI((TreeDictionary) game.getDictionary(), this);
		
		this.difficulty = difficulty;
	}
	
	public ComputerPlayer(GameController game, String name, PlayerType type, ComputerPlayerDifficulty difficulty) {
		this(game, name, type, difficulty, 0, null);
	}

	@Override
	public void play() {
		System.out.println(name + " (computer): I will play now!");
		BoardWord word = ai.getWord();
		
		game.played(word);
	}

	@Override
	public void playAgain() {
		BoardWord word = ai.getNextWord();
		
		game.played(word);		
	}

}
